import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const Dialog = () => import('../views/Dialog.vue');
const BarChart = () => import('../views/BarChart.vue');
const LineChart = () => import('../views/LineChart.vue');
const PieChart = () => import('../views/PieChart.vue');

const routes = [
  {
    path: '/',
    component: Dialog
  },{
    path: '/bar',
    component: BarChart
  },{
    path: '/line',
    component: LineChart
  },{
    path: '/pie',
    component: PieChart
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router;

router.beforeEach((to, from, next) => {
  if (to.path == '/' || sessionStorage.getItem('loaded') != null) {
    next();
  } else {
    next({
      path: '/'
    });
  }
});
